|
Variables In addition to usage of aliases, there is one more way, which allows to set more understandable names for DB fields (and not only for them). One can compare a DB field name, as well as any expression, to the variable. To operate with variables in FastReport, select the "Report|Variables..." menu item, and then click "Variables" in the toolbar. The list of variables in FastReport has a two-level structure. The first level contains categories, and the second contains the variables themselves. Categorization of the variables is designed for convenience when a list of variables is too long. A list must contain at least one category. That means, that the variables cannot be located at the upper level. Furthermore, categories are needed for logical variables classification only, therefore, they are not included in reports. That is why, when setting a name for a variable, do not forget that it must be unique; it is impossible to create two identical variables in different categories. Let us illustrate use of variables by the following example. Assume we have two data sources: the first is "frxDBDataSet1" with the "CustNo" and "Name" fields and the second is "frxDBDataSet2" with the "OrderNo" and "Date" fields. We can compare the following list of variables to the fields: Clients where "Clients" and "Orders" are two categories. Let us open the variables editor and create a required structure with the help of the "New category," "New variable," and "Edit" buttons. To compare the variables to the DB fields, let us select a variable and double-click on the required DB field in the right part of the window. The link to the DB field will be moved to the bottom of the window. An expression at the bottom of the window would be the value of variable. If it were necessary, it can be edited manually. The categories must not be compared to anything.
After the list of variables is created, close the variables editor. Now we need to insert the variables into the report. In contrast to inserting DB fields, there are fewer variants here. We can either insert a variable into the object text manually by typing the "[Client number]" text, or drag a variable from the "Data" service window to the required place of the report. In the second case, it is required to switch to the "Variables" bookmark in this window. |